package com.guan.serviceStatistics.controller;


import com.guan.commonutils.R;
import com.guan.serviceStatistics.client.UcenterClient;
import com.guan.serviceStatistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author yaobai
 * @since 2023-04-25
 */
@RestController
@RequestMapping("/serviceStatistics/statistics-daily")
@CrossOrigin
public class StatisticsDailyController {


    @Autowired
    private StatisticsDailyService dailyService;

    /**
     * @date: 2023/4/25 17:18
     * @author: 管奇安
     * @description: 统计某一天的注册人数
     * @param: [day]
     * @return: com.guan.commonutils.R
     **/
    @PostMapping("registerCount/{day}")
    public R createStatisticsByDate(@PathVariable String day) {
        dailyService.createStatisticsByDay(day);
        return R.ok();
    }

    /**
     * @date: 2023/4/25 22:41
     * @author: 管奇安
     * @description: 图表显示，返回两个数组：日期json数组 数量json数组
     * @param: [begin, end, type]
     * @return: com.guan.commonutils.R
     **/
    @GetMapping("show-chart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String, Object> map = dailyService.getChartData(begin, end, type);
        return R.ok().data(map);
    }



}

